class Generator < ActiveRecord::Migration
  def self.up
  	
 @role_ids= Hash.new
  	i=0
  	for role in SystemRole.find(:all)
  		@role_ids[i]=role.id
  		i+=1
  	end
  	
  	@position_ids=Hash.new
  	i=0
  	for position in Position.find(:all)		#wczesniej bylo losowane -- :role_id=>@role_ids[rand(@role_ids.length)]
  		@position_ids[i]=position.id
  		i+=1
  	end
  	@position=Position.find(:first,:conditions=>"name='Academic'")
  	student_id=Position.find_by_name("Student").id
  	0.upto(10) do |x|	  		
		User.create!(:login => 'ala'<<(x+1).to_s,:PASSWORD => '123',
  					:position_id=> student_id	, :role_id=>@role_ids[rand(@role_ids.length)] , :expiry_date=> Time.now,:activated=>'y',
 					:email=>'ala@pollster.pl',:study_period=>'2006-2009')
	end
 
	
	
  	
  end

  def self.down
  	User.delete_all
  	
  	
  end
end
